#ifndef DYN_PLANARBILLIARD_ARCLENGTHFUNCTION_H
#define DYN_PLANARBILLIARD_ARCLENGTHFUNCTION_H

#include <cmath>

#include "../utilities/dyn_functor.h"

/*! \author Joey Dumont <joey.dumont@gmail.com>
 *
 *  \date 2012-10-07
 *
 *  \brief Computes the arc length of a curve given in polar coordinates.
 *
 * Given the boundary function \f$r(\varphi)\f$ and its first
 * derivative, this returns the arc length function at a given
 * angle, that is, since
 *  \f[
 *      S = \int_0^\varphi \sqrt{r(\varphi')^2+r'(\varphi')^2}d\varphi',
 *  \f]
 * this function returns the value of the integrand.
 */

class ArcLengthFunction : public Functor
{
public:
    /*! Constructor accepts the boundary and its first derivative. */
    ArcLengthFunction(Functor& _boundary,
                      Functor& _diffBoundary);

    /*! @name Accessor Functions. */
    //@{
    Functor& getBoundary(){return boundary;}
    Functor& getDiffBoundary(){return diffBoundary;}

    void setBoundary(Functor& _boundary){boundary=_boundary;}
    void setDiffBoundary(Functor& _diffBoundary){diffBoundary=_diffBoundary;}
    //@}

    double operator()(const double x);

protected:
    /*! @name Member variables. */
    //@{
    Functor& boundary;
    Functor& diffBoundary;
    //@}
};

#endif // DYN_PLANARBILLIARD_ARCLENGTHFUNCTION_H
